import { PaymentWeChatMpGateway, PaymentWeChatMp, PaymentWxmpInterfaceWithDerive, PutRes, patchPaymentWxmpDto } from "qqlx-core";

import { ViewBase } from "@view/view-base";

export class ViewPayWxmp extends ViewBase<PaymentWeChatMp> implements PaymentWxmpInterfaceWithDerive<{}> {
  private static instance: ViewPayWxmp;
  static getInstance(options?: { isSingleton?: boolean }) {
    if (options?.isSingleton === false) {
      return new ViewPayWxmp();
    }

    if (!this.instance) this.instance = new ViewPayWxmp();
    return this.instance;
  }

  private constructor() {
    super();
    this.initial();
    this.insertDefaultCondition();
  }

  async patch(dto: patchPaymentWxmpDto) {
    this.pending();
    const path = PaymentWeChatMpGateway.path;
    return this.$request.patch<patchPaymentWxmpDto, PutRes<PaymentWeChatMp>>(path, dto);
  }
}
